<?php

$dbconf = array(
    'host' => 'localhost',
    'user' => 'root',
    'pass' => '',
    'database' => 'prism'
);

class DB {
    private $mysqli;
    
    /* Constructor: setup connection */
    public function __construct($host, $user, $pass, $database) {
	    		
	
    }
    
   
    
    /* Check login information */
    public function checkLogin($login, $password) {
if(!($stmt = $this->mysqli->prepare('SELECT pmac, pmpw '.
                                    'FROM pm '.
                                    'WHERE login=? AND password=?'))) {
 		   throw new Exception('DB Error: '.$this->mysqli->error);
		}

		$stmt->bind_param('ss', $login, $password);
		if(!$stmt->execute()) {
		    throw new Exception('DB Error: '.$this->mysqli->error);
		}

		$stmt->bind_result($id, $name);
		if($stmt->fetch()) {
		    $stmt->close();
 		   return true;
		} else {
		    $stmt->close();
 		   return false;
		}

	
	
    }
};

// Create a DB object $db. We will use $db to connect to database in catalog.php
$db = new DB($dbconf['host'], 
             $dbconf['user'], 
			 $dbconf['pass'], 
			 $dbconf['database']);

?>